<template>
    <div>
        <ElButton @click="onBtnClick">下载数据并更新</ElButton>
        <el-skeleton :rows="5" animated :loading="loading">
            <ElTable :data="tableData" border style="width: 100%"  >
                <ElTableColumn prop="product_id" label="product_id" width="180" />
                <ElTableColumn prop="unit_net_value" label="unit_net_value" width="180" />
                <ElTableColumn prop="daily_inc_perc" label="daily_inc_perc" />
                <ElTableColumn prop="trade_dt" label="trade_dt" />
            </ElTable>
        </el-skeleton>
        {{ msg }}
    </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue'
import { updateNetValue } from '@/app/finace/api'

const msg = ref('')
const loading = ref(true)
const tableData = ref([
    {
        date: '2016-05-03',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
    {
        date: '2016-05-02',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
    {
        date: '2016-05-04',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
    {
        date: '2016-05-01',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
])

onMounted(() => {
    loading.value = false
})
function onBtnClick() {
    console.log('点击了')
    tableData.value = []
    loading.value = true

    updateNetValue().then(res => {
        console.log('成功', res)
        msg.value = res
        tableData.value = res
        console.log(msg)
        loading.value = false
    }).catch(err => {
        console.log('失败', err)
        loading.value = false
    })
}
// request.get('/api/finace/update_nv').then(res=>{
//     console.log('成功',res)
// }).catch(err=>{
//     console.log('失败',err)
// })

</script>